<script setup lang="ts">
import {onMounted, ref} from "vue";

const username = ref('')

onMounted(() => {
  const storedUsername = localStorage.getItem('username')
  if (storedUsername) {
    username.value = storedUsername
  } else {
    username.value = '游客' // 默认显示“游客”或其他默认值
  }
})
</script>

<template>
  <!-- 账户信息卡片 -->
  <el-card shadow="hover" style="margin-bottom: 20px;">
    <template #header>
      <div>账户信息</div>
    </template>
    <el-row :gutter="20" align="middle">
      <!-- 头像占位（可替换为真实头像） -->
      <el-col :span="4">
        <img
            src="https://via.placeholder.com/80"
            alt="avatar"               style="border-radius: 50%;"
        >
      </el-col>
      <el-col :span="20">
        <div class="username">{{ username }}</div> <!-- 动态显示用户名 -->
        <div class="status" style="color: #67c23a;">在线</div>
      </el-col>
    </el-row>
  </el-card>

  <!-- 快捷操作卡片 -->
  <el-card shadow="hover" style="margin-bottom: 20px;">
    <template #header>
      <div>快捷操作</div>
    </template>
    <el-row :gutter="20">
      <el-col :span="8">
        <el-button type="primary" block>充值</el-button>
      </el-col>
      <el-col :span="8">
        <el-button type="info" block>隐私设置</el-button>
      </el-col>
      <el-col :span="8">
        <el-button type="success" block>账户明细</el-button>
      </el-col>
    </el-row>
  </el-card>

  <!-- 详细信息卡片 -->
  <el-card shadow="hover">
    <template #header>
      <div>详细信息</div>
    </template>
    <el-form label-width="120px">
      <el-form-item label="好友代码">
        <el-input readonly value="1386563620" />
      </el-form-item>
      <el-form-item label="电子邮箱">
        <el-input readonly value="18476719331@163.com" />
      </el-form-item>
      <el-form-item label="VAC 状态">
        <el-tag type="success">无封禁</el-tag>
      </el-form-item>
      <el-row justify="end">
        <el-col :span="6">
          <el-form-item label="" class="custom-right-align">
            <!-- 如果需要按钮或其他组件可以放在这里 -->
            <el-button type="primary">添加好友</el-button>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </el-card>
</template>

<style scoped>
.username {
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 8px;
}
.status {
  font-size: 14px;
}
</style>